package views.inventory;

import java.awt.event.ActionListener;

import javax.swing.JPanel;
import javax.swing.SpringLayout;
import javax.swing.JSeparator;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

import java.awt.Dimension;
import java.awt.Font;
import javax.swing.border.BevelBorder;
import javax.swing.DefaultComboBoxModel;

public class StockReport extends JPanel{
	
	//private static final long serialVersionUID = 1L;
	private JButton btnGenerate;
	private JComboBox catagoryCombo;
	private JComboBox SellerNameCombo;
	private JComboBox sizeCombo;
	private JTable table;
	
	public StockReport() 
	{
		SpringLayout springLayout = new SpringLayout();
		setLayout(springLayout);
		
		setSize(870,550);
		
		JLabel lblCatagory = new JLabel("Catagory");
		lblCatagory.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.WEST, lblCatagory, 30, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.NORTH, lblCatagory, 30, SpringLayout.NORTH, this);
		add(lblCatagory);
		
		catagoryCombo = new JComboBox();
		catagoryCombo.setModel(new DefaultComboBoxModel(new String[] {"--Select Catagory--"}));
		catagoryCombo.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, catagoryCombo, 6, SpringLayout.SOUTH,lblCatagory );
		springLayout.putConstraint(SpringLayout.WEST, catagoryCombo, 30, SpringLayout.WEST,this);
		add(catagoryCombo);
		catagoryCombo.setPreferredSize(new Dimension(200, 23));
		
		SellerNameCombo = new JComboBox();
		SellerNameCombo.setModel(new DefaultComboBoxModel(new String[] {"--Select Seller Name--"}));
		SellerNameCombo.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.WEST, SellerNameCombo, 30, SpringLayout.EAST, catagoryCombo);
		springLayout.putConstraint(SpringLayout.NORTH, SellerNameCombo, 0, SpringLayout.NORTH, catagoryCombo);
		add(SellerNameCombo);
		SellerNameCombo.setPreferredSize(new Dimension(200, 23));
		
		JLabel lblSellerName = new JLabel("Seller Name");
		lblSellerName.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH,lblSellerName, 30, SpringLayout.NORTH,this );
		springLayout.putConstraint(SpringLayout.WEST, lblSellerName, 0, SpringLayout.WEST, SellerNameCombo);
		add(lblSellerName);
		
			
		sizeCombo = new JComboBox();
		sizeCombo.setModel(new DefaultComboBoxModel(new String[] {"--Select Size--"}));
		sizeCombo.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.WEST, sizeCombo, 30, SpringLayout.EAST, SellerNameCombo);
		springLayout.putConstraint(SpringLayout.NORTH, sizeCombo, 0, SpringLayout.NORTH, SellerNameCombo);
		add(sizeCombo);
		sizeCombo.setPreferredSize(new Dimension(200, 23));
		
		JLabel lblSize = new JLabel("Size");
		lblSize.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.WEST, lblSize, 0, SpringLayout.WEST, sizeCombo);
		springLayout.putConstraint(SpringLayout.NORTH,lblSize,30, SpringLayout.NORTH, this);
		add(lblSize);
	
		btnGenerate = new JButton("GENERATE");
		btnGenerate.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.WEST, btnGenerate, 30, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.NORTH, btnGenerate, 30, SpringLayout.SOUTH,catagoryCombo );
		add(btnGenerate);
		btnGenerate.setActionCommand("GENERATE");
		
		JSeparator separator = new JSeparator();
		springLayout.putConstraint(SpringLayout.NORTH, separator, 30, SpringLayout.SOUTH, btnGenerate);
		springLayout.putConstraint(SpringLayout.WEST, separator, 30, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.EAST, separator, -30, SpringLayout.EAST, this);
		add(separator);
		
		
		JScrollPane scrollPane = new JScrollPane();
		springLayout.putConstraint(SpringLayout.SOUTH, scrollPane, -30, SpringLayout.SOUTH, this);
		springLayout.putConstraint(SpringLayout.NORTH, scrollPane, 30, SpringLayout.SOUTH, separator);
		springLayout.putConstraint(SpringLayout.WEST, scrollPane, 30, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.EAST, scrollPane, -30, SpringLayout.EAST, this);
		add(scrollPane);
		
		table = new JTable();
		table.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"SELLERNAME", "CATEGORY", "SIZE", "PURCHASE QUANTITY","REMAINING QUANTITY"
			}
		) {
			boolean[] columnEditables = new boolean[] {
				false, false, false, false
			};
			public boolean isCellEditable(int row, int column) {
				return columnEditables[column];
			}
		});
		scrollPane.setViewportView(table);
	}
	
	
	public void actionListener(ActionListener al)
	{
		btnGenerate.addActionListener(al);
	}


	public JButton getBtnGenerate() {
		return btnGenerate;
	}


	public void setBtnGenerate(JButton btnGenerate) {
		this.btnGenerate = btnGenerate;
	}


	

	public JComboBox getLevel3Combo() {
		return catagoryCombo;
	}


	public void setLevel3Combo(JComboBox level3Combo) {
		catagoryCombo = level3Combo;
	}


	public JComboBox getSellerNameCombo() {
		return SellerNameCombo;
	}


	public void setSellerNameCombo(JComboBox sellerNameCombo) {
		SellerNameCombo = sellerNameCombo;
	}


	public JComboBox getSizeCombo() {
		return sizeCombo;
	}


	public void setSizeCombo(JComboBox sizeCombo) {
		sizeCombo = sizeCombo;
	}


	public JTable getTable() {
		return table;
	}


	public void setTable(JTable table) {
		this.table = table;
	}


	
	
	public void actionlisteners(ActionListener al)
	{
		this.btnGenerate.addActionListener(al);
	}
	
}
